<!-- 继承公共视图文件 -->
<extend name="./Application/Admin/View/layout.html" />
 <!-- 可变内容区域 -->
<block name="mid">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="panel-heading">
                <h2><i class="fa fa-indent red"></i><strong>&nbsp;&nbsp;添加品牌</strong></h2>
            </div>
        </div>
        <hr class="layui-bg-black">

        <div class="layui-col-md6 layui-col-md-offset3" style="margin-top: 30px;">
          <form class="layui-form" action="" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">品牌名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required  lay-verify="required" placeholder="例：兰蔻/法兰琳卡" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">链接</label>
                <div class="layui-input-block">
                    <input type="text" name="http" placeholder="例：市场经理" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">显示</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_show" value="1" title="是" checked>
                    <input type="radio" name="is_show" value="0" title="否">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">排序</label>
                <div class="layui-input-block">
                    <input type="text" name="sort" placeholder="例：市场经理" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">LOGO</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn"  id="logo">上传图片</button>
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" id="demo1">
                            <p id="demoText"></p>
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
          </form>
        </div>
    </div>

</block>
<block name="js">

    <script type="text/javascript" src="__ADMIN__assets/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="__ADMIN__assets/js/jquery.validate.min.js"></script>
	<script type="text/javascript">
		$(function(){

            //logo图片上传
            var uploadInst = upload.render({
                elem: '#logo',
                url: "{:U('admin/ajax/logo')}",
                before: function(obj){
                  //预读本地文件示例，不支持ie8
                  obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                  });
                },
                done: function(res){
                  //如果上传失败
                  if(res > 0){
                    return layer.msg('上传成功');
                  }else{
                    return layer.msg('上传失败');
                  }
                  //上传成功
                },
                error: function(){
                  //演示失败状态，并实现重传
                  var demoText = $('#demoText');
                  demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                  demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                  });
                }
            })

		})
	</script>
</block>